package 力扣;

import java.util.PriorityQueue;
import java.util.Queue;

/**
 * @author yyq
 * @create 2022-03-28 14:08
 */
public class leetcode225 {

}
class MyStack {
    Queue<Integer> queue;
    Queue<Integer> temp;
    public MyStack() {
        queue=new PriorityQueue<>();
        temp=new PriorityQueue<>();
    }

    public void push(int x) {
        queue.add(x);

    }

    public int pop() {
        while (queue.size()!=1){
            temp.add(queue.poll());
        }
        int pop=queue.poll();
        while(!temp.isEmpty()){
            queue.add(temp.poll());
        }
        return pop;


    }

    public int top() {
        while (queue.size()!=1){
            temp.add(queue.poll());
        }
        int pop=queue.poll();
        while(!temp.isEmpty()){
            queue.add(temp.poll());
        }
        queue.add(pop);
        return pop;
    }

    public boolean empty() {
        if(queue.isEmpty()) return true;
        else return false;
    }
}
